/*
 * @Descripttion: 
 * @version: V1.0.0
 * @Author: LeonHe
 * @Date: 2021-05-29 20:10:18
 * @LastEditTime: 2021-05-29 20:18:55
 */
#ifndef __COMMON_FILTER_H_
#define __COMMON_FILTER_H_

#include "main.h"
#include "arm_math.h"

typedef struct
{
    uint8_t deepth;
    uint8_t index;
    q15_t*  buff;
    q31_t   sum;
}avgFilterQ15StDef;

typedef struct
{
    uint8_t deepth;
    uint8_t index;
    q15_t*  buff;
    q31_t   sum;
    q15_t   Amplitude;
}avgLimitFilterQ15StDef;

typedef struct
{
    uint8_t deepth;
    uint8_t index;
    q31_t*  buff;
    q63_t   sum;
    q31_t   Amplitude;
}avgLimitFilterQ31StDef;

#define avgFilterQ15_EXPORT(name,deep)              \
        static q15_t sAvgFiltBuf##name[(deep)]={0}; \
        avgFilterQ15StDef name = {                  \
            (deep),                                 \
            0,                                      \
            sAvgFiltBuf##name,                      \
            0,                                      \
        };

#define avgLimitFilterQ15_EXPORT(name,deep,amp)     \
        static q15_t sAvgLimFiltBuf##name[(deep)]={0};  \
        avgLimitFilterQ15StDef name = {             \
            (deep),                                 \
            0,                                      \
            sAvgLimFiltBuf##name,                   \
            0,                                      \
            (amp),                                  \
        };

#define avgLimitFilterQ31_EXPORT(name,deep,amp)     \
        static q31_t sAvgLimFiltBuf##name[(deep)]={0};  \
        avgLimitFilterQ31StDef name = {             \
            (deep),                                 \
            0,                                      \
            sAvgLimFiltBuf##name,                   \
            0,                                      \
            (amp),                                  \
        };

q15_t avgFilterQ15(avgFilterQ15StDef *inst, q15_t in);
q15_t avgLimitFilterQ15(avgLimitFilterQ15StDef *inst, q15_t in);
q31_t avgLimitFilterQ31(avgLimitFilterQ31StDef *inst, q31_t in);


#endif
